
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="com.uniq.db.ConnectionFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@include file="AdminHeader.jsp"%>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script type="text/javascript">
            function submitSource()
            {
                var source=document.getElementById("source").value;
                alert('selected source is '+source);
                document.forms['stock_exchange'].submit();
            }
            
            function exchange()
            {
                alert('submit');
                document.forms['stock_exchange'].action="./Exchange";
                 document.forms['stock_exchange'].submit();
            }
        </script>
        
    </head>
    
    <body>
        
        <form name="stock_exchange">
        Select a Source branch Name (Where product need to released ??)
        <select name="source" action="Exchange"  id="source">
            <%     String source=request.getParameter("source");
            String article_no=request.getParameter("article_no");
            if(source==null)
        {
    %>
            <option>Select Source Branch</option>
            <option value="branch1">Branch 1</option>
            <option value="branch2">Branch 2</option>
            <option value="branch3">Branch 3</option>
      
        <%
            }
   
                                else if(source.equalsIgnoreCase("branch1"))
        {
                                    
                    %>
          <option>Select Source Branch</option>
             <option value="branch1" selected="">Branch 1</option>
            <option value="branch2">Branch 2</option>
            <option value="branch3">Branch 3</option>
            <%
            }
      
                      else if(source.equalsIgnoreCase("branch2"))
        {
              %>
          <option>Select Source Branch</option>
          <option value="branch1" >Branch 1</option>
          <option value="branch2" selected="">Branch 2</option>
          <option value="branch3">Branch 3</option>
            <%
            }
     
                      else if(source.equalsIgnoreCase("branch3"))
        {
              %>
          <option>Select Source Branch</option>
             <option value="branch1" >Branch 1</option>
            <option value="branch2" >Branch 2</option>
            <option value="branch3" selected="">Branch 3</option>
            <%
            }
    %>
      </select>
<%

if(source!=null&&article_no!=null)        
        {
    Connection con=ConnectionFactory.getConnection();
    Statement st=con.createStatement();
    
    ResultSet rs=st.executeQuery("SELECT * from stock where branch='"+source+"' and article_no='"+article_no+"'");
    out.println("<ul class='news_list'>");
    out.println("<table style='width:100%'>");
    int c=0;
     out.println("<th>S no</th>");
     out.println("<th>Product Name</th>");
     out.println("<th>Supplier</th>");
     out.println("<th>Article No</th>");
     out.println("<th>QR image Code</th>");
     
     out.println("<th>Current Stock</th>");
     
     
    while(rs.next())
    {
        c++;
       out.println("<tr>");
       out.println("<td align='center'>"+c+"</td>"); 
       out.println("<td align='center'> Product "+ rs.getString("id") +"</td>"); 
       out.println("<td align='center'>"+rs.getString("supplier")+"</td>"); 
       out.println("<td align='center'>"+rs.getString("article_no")+"</td>"); 
       out.println("<td align='center'><img src=DisplayQrCode?id="+rs.getString("id")+"/></td>"); 
       out.println("<td align='center'>"+rs.getString("stock_count")+"</td>"); 
      
       
       out.println("</tr>");
        
    }
     out.println("<table'>");
     



        }


%>
Article NO:<input type="text" name="article_no"/>
<input type="button" onclick="submitSource()" value="Search"/>
      </form>

    </body>
</html>
